<!-- 应聘推广员分成  应聘推广员分成-->
<template>
  <n-button type="info" quaternary @click="ypzfnsdrr">
    {{ dxdata.isfc == 1?'应聘推广员分成':'应聘推广员分成' }}
    </n-button>
  <n-modal v-model:show="showModal" preset="card" class="asdfsdfdsfdsf">
    <template #header>
      <div>分成</div>
    </template>
    <div>
        <p>应聘者信息</p>
        <div class="fsdfsdrtdsd mt20" v-if="usjeder">
          <div class="">id：{{ usjeder.id }}</div>
          <div class="">姓名：{{ usjeder.name }}</div>
          <div class="">
            等级：{{ usjeder.dengji == 2 ? "VIP" : "普通用户" }}
          </div>
          <div class="">手机号：{{ usjeder.phone }}</div>
          <div class="">邮箱：{{ usjeder.email }}</div>
          <div class="">录用时间：{{ usjeder.lysj }}</div>
          <div class="">
            简历：<a :href="usjeder.jianli" class="sz ls" target="_blank"
              >点击查看</a
            >
          </div>
        </div>

      <n-table :single-line="false" class="mt20">
        <thead>
          <tr>
            <th>分销等级</th>
            <th>应分成ID</th>
            <th>应分成姓名</th>
            <th>应分成邮箱</th>
            <th>会员等级</th>
            <th>分成金额</th>
          </tr>
        </thead>
        <tbody>
          <tr v-for="sd in jdfsddf">
            <td>{{ sd.fxdj }}</td>
            <td>{{ sd.id }}</td>
            <td>{{ sd.name }}</td>
            <td>{{ sd.email }}</td>
            <td>{{ sd.dengji }}</td>
            <td>{{ jsdfsdf(sd.bilie) }}</td>
          </tr>
          <tr>
            <td colspan="5">
              <div class="tr">应分总额</div>
            </td>
            <td>{{ hnhjsdfds(jdfsddf) }}</td>
          </tr>
        </tbody>
      </n-table>
      <div v-if="jdfsddf.length <= 0" class="vertical-center pt30 pm30">
        <div>
          <img src="../../../assets/img/noData.png" style="width: 120px" />
          <p>此账号没有上级</p>
        </div>
      </div>
    </div>
    <template #action>
      <div class="tr">
        <n-button
          type="info"
          v-if="jdfsddf.length > 0 && dxdata.isfc == 1"
          :loading="jdfswesd"
          @click="fenxiaosd"
        >
          确认
        </n-button>
        <n-button @click="showModal = false" class="ml20"> 取消 </n-button>
      </div>
    </template>
  </n-modal>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import { dxget, dxpost, dialog, transferTimeYMDHm } from "../../../util/index";
const showModal = ref(false);
const jdfswesd = ref(false);
const jdfsddf = ref([]);
const usjeder= ref(null)
const emit = defineEmits(["callback"]);
let fczd = "484,485";
let props = defineProps({
  dxdata: { type: Object },
});
const fdnnsd = async (uid) => {
  showModal.value = true;
  const { data } = await dxget("jyc/api/getfenclist?zd=" + fczd, { uid });
  const jdfds = Object.values(data);
  jdfsddf.value = jdfds;
};
const ypzfnsdrr = async() => {
  showModal.value = true;
  const { data } = await dxget("jyc/jycadmin/getjsdfd", {
    uid: props.dxdata.ypzid,
    id: props.dxdata.id,
  });
  usjeder.value = data
  fdnnsd(props.dxdata.ypzid);
};
const jsdfsdf = (sdd) => {
  console.log(props.dxdata);
  try {
    let kjjdfsd = (props.dxdata.zpjiage * sdd).toFixed(2);
    return `订单金额(${props.dxdata.zpjiage})*比列(${(sdd * 100).toFixed(
      2
    )}%)=${kjjdfsd}`;
  } catch (e) {
    return "--";
  }
  return "--";
};
const hnhjsdfds = (data) => {
  let jdfds = 0;
  data.map((a) => {
    let jsdfs = parseFloat(props.dxdata.zpjiage * a.bilie);
    jdfds += jsdfs;
  });
  return jdfds.toFixed(2);
};

const fenxiaosd = async () => {
  jdfswesd.value = true;
  const { data } = await dxpost("jyc/api/shoudongchufa", {
    zd: fczd,
    uid: props.dxdata.ypzid,
    jiner: props.dxdata.zpjiage,
    beizhu: "应聘推广员分成",
  });
  await dxpost(
    "jyc/zhaoping/zhaoping",
    { id: props.dxdata.id, isfc: 2, fcsj: transferTimeYMDHm() },
    "put"
  );
  await gxmisndf();
  jdfswesd.value = false;

  showModal.value = false;
  // initeer()
  emit("callback");
};
const gxmisndf = async () => {

//   await dxpost(
//     "jyc/miansi/miansi",
//     {
//       id: usjeder.value.msid,
//       fcsj: transferTimeYMDHm(),
//       isfc: 2,
//     },
//     "put"
//   );
};
</script>
<style scoped></style>
